package cn.edu.hunau.oop.day07;

import org.junit.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author hb
 * @date 2025-08-12 16:30:04
 */
public class TestSet {
    @Test
    public void testEqulas(){
        Set<Apple> set=new HashSet<>();
        set.add(new Apple("红富士","red",100));
        set.add(new Apple("红富士","green",120));
        set.add(new Apple("红富士","red",110));
        set.add(new Apple("红富士","red",100));
        System.out.println(set.size());
        System.out.println(set);


    }

    @Test
    public void test(){
        Set<String> set=new HashSet<>();
        set.add("lucy");
        set.add("lily");
        set.add("lilei");
        set.add("lily");
        //[lilei, lily, lucy]
        System.out.println(set);

        //set的遍历
        for(String s:set){
            System.out.println(s);
        }

        //迭代器
        Iterator<String> iter = set.iterator();
        while(iter.hasNext()){
            String value=iter.next();
            System.out.println(value);
        }
    }
}
